package com.ims.service.impl;

import com.ims.dao.DaoSupport;
import com.ims.entity.Page;
import com.ims.entity.system.User;
import com.ims.service.UserService;
import com.ims.util.PageData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource(name = "daoSupport")
    private DaoSupport dao;

    @Override
    public PageData findByUiId(PageData pd) throws Exception {
        return (PageData)dao.findForObject("UserXMapper.findByUiId", pd);
    }

    @Override
    public PageData findByUId(PageData pd) throws Exception {
        return (PageData)dao.findForObject("UserXMapper.findByUId", pd);
    }

    @Override
    public void saveU(PageData pd) throws Exception {
        dao.save("UserXMapper.saveU", pd);
    }

    @Override
    public void editU(PageData pd) throws Exception {
        dao.update("UserXMapper.editU", pd);
    }

    @Override
    public void deleteU(PageData pd) throws Exception {
        dao.delete("UserXMapper.deleteU", pd);
    }

    @Override
    public void deleteAllU(String[] USER_IDS) throws Exception {
        dao.delete("UserXMapper.deleteAllU", USER_IDS);
    }

    @Override
    public List<PageData> listPdPageUser(Page page) throws Exception {
        return (List<PageData>) dao.findForList("UserXMapper.userlistPage", page);
    }

    @Override
    public List<PageData> listAllUser(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("UserXMapper.listAllUser", pd);
    }

    @Override
    public PageData getUserByNameAndPwd(PageData pd)  {
        return (PageData)dao.findForObject("UserXMapper.getUserInfo", pd);
    }

    @Override
    public void setSKIN(PageData pd)throws Exception{
        dao.update("UserXMapper.setSKIN", pd);
    }

    @Override
    public User getUserAndRoleById(String USER_ID) throws Exception {
        return (User) dao.findForObject("UserMapper.getUserAndRoleById", USER_ID);
    }


}
